package com.qzsoft.zhjd.third.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.jeemis.common.validator.ValidatorUtils;
import com.qzsoft.jeemis.platform.security.dto.LoginDTO;
import com.qzsoft.jeemis.platform.security.service.BasicLoginService;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName ThirdLoginController
 * @Description 第三方应用登录
 * @author linhuawei
 * @since 2021-10-25
 */
@Slf4j
@RestController
@RequestMapping("/api/third")
public class ThirdLoginController {

    @Autowired
    private BasicLoginService basicLoginService;

    /**
     * @Title login
     * @Description 第三方应用登录获取token信息
     * @param request
     * @param login
     * @return
     */
    @SuppressWarnings("rawtypes")
    @PostMapping("login")
    public Result login(HttpServletRequest request, @RequestBody LoginDTO login) {
        ValidatorUtils.validateEntity(login, new Class[0]);
        log.info("" + login);
        return basicLoginService.login(request, login);
    }

}
